<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="dist/vue.js"></script>
</head>
<body>
    <div id="app">
        {{ obj }}
    </div>
</body>
<script>
    const vm = new Vue({
        el: '#app',
        data: {
           obj: {
               a:{
                   b: 2
               }
           }
        },
        watch: {
            // obj(newVal, oldVal){
            //     console.log(newVal, oldVal);
            //     console.log("watched", this.obj);
            // },
            obj: {
                handler(newVal, oldVal) {
                    console.log(newVal, oldVal);
                    console.log('deep watch', this.obj);
                },
                immmediate:true,
                deep:true, //必须加的选项的
            }
            // ,
            // 'obj.a.b':function(newVal, oldVal) {
            //     console.log('指定监听属性',newVal, oldVal);
            //     console.log('点watch的方法', this.obj);
            // }
        }
    })
</script>
</body>
</html>